package chouXiangLeiHeJieKou.ChouXiangLeiHeJieKou2.demo5;

import javax.jws.Oneway;

class OutClass{
    public int data1=1;
    private int data2=2;
    public static int data3=3;

    //静态内部类
    static class InnerClass{
        public int data4=4;
        private int data5=5;
        public static int data6=6;

        public void test(){
            OutClass outClass=new OutClass();
            System.out.println(outClass.data1);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
            System.out.println("test方法被执行了...");
        }
    }
}

class Outclass2{
    public int data1=1;
    private int data2=2;
    public static int data3=3;
    //内部类
    class InnerClass2{
        public int data1=1000;
        public int data4=4;
        private int data5=5;
        //public static int data6=6;

        public void test(){
            Outclass2 outclass2=new Outclass2();
            System.out.println(outclass2.data1);
           // System.out.println(outclass2.this.data1);
            System.out.println(this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            //System.out.println(data6);
            System.out.println("test()方法被执行了....");
        }
    }
}

class Out{
    public void test1(){
        System.out.println("haha");
    }
    interface IA{
        void test1();
    }
}
public class Test {
    public static void main1(String[] args) {
        //这个类 实现了IA 接口 并且同时重写了test1这个方法
        Out.IA a = new Out.IA() {
            @Override
            public void test1() {
                System.out.println("hahahahah");
            }
        };
        a.test1();
       /*new Out(){

       }.test1();*/
        //第二种重写
        /* new Out(){
          @Override
           public void test1(){
            System.out.println("heihei");
            }
        }.test1();*/

    }
    public void testMethod(){
        //局部内部类
        class Inner{
            public int data1;
            public void func(){
                System.out.println("func");
            }
        }
        Inner inner=new Inner();
        inner.func();
    }

    public static void main2(String[] args) {
        //如何实例一个内部类对像
        Outclass2 outclass2=new Outclass2();

        Outclass2.InnerClass2 innerClass2=outclass2.new InnerClass2();
        innerClass2.test();
    }

    public static void main(String[] args) {
        //如何实例化一个静态内部对象
        OutClass.InnerClass innerClass=new OutClass.InnerClass();
        innerClass.test();
    }
}
